/**
 * Created by sxh on 2018/4/18.
 */
define(['jquery', 'angular', 'app.services', 'require'],function($, angular, services,  require){
    'use strict';

    services.service('jewelleryService', ['$resource','Base',function ($resource,Base) {
        /*--------------------------------------商品------------------------*/
        //商品列表
        this.webGetGoodsList = function (pageIndex,pageSize,goodsParam,success,error) {
            return $resource(Base.stringFormat("/api/webGoods/list/:pageIndex/:pageSize"),{pageIndex:pageIndex,pageSize:pageSize}).save(goodsParam,success,error);
        };
        //商品分类
        this.getGoodsTypeList = function(success,error){
            return $resource(Base.stringFormat("/api/webGoods/getGoodNav")).get(success,error);
        };
        //商品详情
        this.webGetGoodsDeatil = function(goodsId,success,error){
            return $resource("/api/webGoods/get/:goodsId",{goodsId:goodsId}).get(success,error);
        };
        //获取商品所有图片
        this.webGetGoodsPic = function(goodId,success,error){
            return $resource("/api/webGoods/getAllPic/:goodId",{goodId:goodId}).get(success,error);
        };
        //分页查询商品评价信息
        this.webGoodsEvaList = function (goodsId,pageIndex,pageSize,success,error) {
            return $resource(Base.stringFormat("/api/webGoods/getList/:goodsId/:pageIndex/:pageSize"),{goodsId:goodsId,pageIndex:pageIndex,pageSize:pageSize}).get(success,error);
        };
        //根据商品id规格及用户查询购物车
        this.webCartByUGId =function(goodsId,goodsweightId,success,error){
            return $resource(Base.stringFormat("/api/webSCart/getCartByUGId/"+ goodsId+"/"+goodsweightId)).get(success,error);
        }
        //加入购物车
        this.addShopCart = function(param,success,error){
            return $resource(Base.stringFormat("/api/webSCart/add")).save(param,success,error);
        };
        /*-------------------------------购物车+优惠券----------------------------------*/
        //查询我的购物车
        this.getWebCartList = function(success,error){
            return $resource(Base.stringFormat("/api/webSCart/getList")).get(success,error);
        };
        //购物车修改商品数量
        this.updateWebSCartNumber = function(goodsId,number,success,error){
            return $resource(Base.stringFormat("/api/webSCart/updateNumber/"+ goodsId+"/"+number)).get(success,error);
        };
        //删除购物车商品信息
        this.deleteWebSCartGoods = function(goodsId,goodsWeightId,success,error){
            return $resource(Base.stringFormat("/api/webSCart/delete/"+goodsId+"/"+goodsWeightId)).get(success,error);
        };
        //我的优惠券
        this.getWebCouponList = function(success,error){
            return $resource(Base.stringFormat("/api/webSCart/getUserCouponList")).get(success,error);
        };
        //提交订单
        this.addWebOrderDetail = function(orderDetail,success,error){
            return $resource(Base.stringFormat("/api/webSCart/addOrder")).save(orderDetail,success,error);
        };
        /*--------------------------------订单------------------------------*/
        //获取订单列表
        this.getOrderList = function (orderParam,pageIndex,pageSize,success,error) {
            return $resource(Base.stringFormat("/api/webOrder/getList/:pageIndex/:pageSize"),{pageIndex:pageIndex,pageSize:pageSize}).save(orderParam,success,error);
        };
        //删除订单
        this.deleteOrderStatus = function(orderId,success,error){
            return $resource("/api/webOrder/delete/:orderId",{orderId:orderId}).get(success,error);
        };
        //根据id获取订单列表
        this.getOrderById = function (orderId,success,error) {
            return $resource(Base.stringFormat("/api/webOrder/getOrder/:orderId"),{orderId:orderId}).get(success,error);
        };
        //查询商品评价信息
        this.getEvaluate = function(orderId,goodsId,success,error){
            return $resource(Base.stringFormat("/api/webEvaluate/getEvaluate/"+orderId+"/"+goodsId)).get(success,error);
        };
        //添加评价信息
        this.addEvaluate=function(param,success,error){
            return $resource(Base.stringFormat("/api/webEvaluate/add")).save(param,success,error);
        };
        //旧物交易展示列表信息
        this.getOldList = function(param,pageIndex,pageSize,success,error){
            return $resource("/api/webOld/getList/:pageIndex/:pageSize",{pageIndex:pageIndex,pageSize:pageSize}).save(param,success,error);
        };
        //删除旧物
        this.deleteOld=function (oldId,success,error) {
            return $resource(Base.stringFormat("/api/webOld/delete/:oldId"),{oldId:oldId}).delete(success,error);
        };
        //根据goodsId获取商品信息
        this.getOldById=function (id,success,error) {
            return $resource(Base.stringFormat("/api/webOld/getOldById/:id"),{id:id}).get(success,error);
        };
        //修改旧物
        this.updateOld = function (old,success,error) {
            return $resource(Base.stringFormat("/api/webOld/update"), null, {'save': {method: 'PUT'}}).save(old,success, error);
        };
        //添加商品
        this.addOld=function (old,success,error) {
            return $resource(Base.stringFormat("/api/webOld/add")).save(old,success,error);
        };
        //获取商品类型列表
        this.getGType=function (type,success,error) {
            return $resource(Base.stringFormat("/api/gType/GTypelist/:type"),{type:type}).get(success,error);
        }
        //获取商品样式列表
        this.getGStyle=function (success,error) {
            return $resource(Base.stringFormat("/api/gStyle/getGStyleList")).get(success,error);
        }
        //删除展示图片
        this.deleteOldIconUrl=function(id,success,error){
            return $resource(Base.stringFormat("/api/webOld/updateIconUrl/:id"),{id:id}).get(success,error);
        };

        //修改密码
        this.updateUserPwd = function(oldPwd,newPwd,success, error) {
            return $resource("/api/user/updatePwd/:oldPwd/:newPwd",{oldPwd:oldPwd,newPwd:newPwd}).get(success, error);
        }
        //我的优惠券
        this.getUserCouponList = function(success, error) {
            return $resource("/api/userCoupon/getUserCouponList").get(success, error);
        }
        //获取三级列表菜单
        this.getGoogsTypeList = function(success,error){
            return $resource("/dapi/mGoodType/getGoodNav").get(success,error);
        };
    }]);

});